/<template>
  <div>
      <Swiper></Swiper>
      <dl v-for="(item,index) in list" :key="index">
          <dt><img :src="item.img" alt="" @click="render(item.id)"></dt>
          <dd @click="change(item.id)">{{item.price}}</dd>
      </dl>
  </div>
</template>

<script>
import axios from "axios"
import Swiper from "../../components/Swiper.vue"
export default {
    components: {
        Swiper
    },
    data(){
        return{
            list:[]
        }
    },
    mounted() {
        axios.get("/list").then((res)=>{
            this.list=res.data;
            console.log(res.data);
        })
    },
    methods: {
        change(id){
             this.$router.push({
                path: '/detail2',
                query: {
                    // url的参数, 类似get请求的传参
                    id
                },
            })
        },
        render(id) {
            console.log(id);
           
            this.$router.push({
                name: 'Detail',
                params: {
                    // url的参数, 类似get请求的传参
                    id
                },
            })
        },
    },
}
</script>

<style>

</style>